package com.iqik.base.task.elastic;

import com.dangdang.ddframe.job.config.JobCoreConfiguration;
import com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration;
import com.dangdang.ddframe.job.lite.api.JobScheduler;
import com.dangdang.ddframe.job.lite.config.LiteJobConfiguration;
import com.dangdang.ddframe.job.reg.base.CoordinatorRegistryCenter;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration;
import com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter;

public class ElasticDemo {

    public static void main(String[] args) {
        // 配置分布式协调服务（注册中心 zookeeper）
        ZookeeperConfiguration zookeeperConfiguration = new ZookeeperConfiguration("132.232.16.135:2181", "my-zookeeper");
         CoordinatorRegistryCenter coordinatorRegistryCenter = new ZookeeperRegistryCenter(zookeeperConfiguration);
         coordinatorRegistryCenter.init();
        // 配置任务
        JobCoreConfiguration build = JobCoreConfiguration.newBuilder("elastic-job", "*/2 * * * * ?", 1).build();
        SimpleJobConfiguration simpleJobConfiguration = new SimpleJobConfiguration(build, ElasticDemoJob.class.getName());
        JobScheduler jobScheduler = new JobScheduler(coordinatorRegistryCenter, LiteJobConfiguration.newBuilder(simpleJobConfiguration).overwrite(true).build());
        jobScheduler.init();
        /**
         * ZooInspector
         https://issues.apache.org/jira/secure/attachment/12436620/ZooInspector.zip；
         */
    }
}
